tg-me.com/java_codings/13
Last Update:
9. Program to Calculate Binary Number Calculation.
import java.util.*;
class BinaryCalculator
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("First Binary: ");
String binOne = in.next();
System.out.print("Second Binary: ");
String binTwo = in.next();
int left = Integer.parseInt(binOne, 2);
int right = Integer.parseInt(binTwo, 2);
System.out.println("Sum of the binary numbers : " + Integer.toBinaryString(left + right));
System.out.println("Difference of the binary numbers : " + Integer.toBinaryString(left - right));
System.out.println("Product of the binary numbers : " + Integer.toBinaryString(left * right));
System.out.println("Quotient of the binary numbers : " + Integer.toBinaryString(left / right));
}
}
@java_codings
BY Advance Java π¨βπ»
Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283
Share with your friend now:
tg-me.com/java_codings/13